package com.qch.rocket.demo.producer;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * @Author qch
 * 死信队列
 * @Date 2021/6/9
 */
public class MyDelayProducer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer_10_grp_01");
        producer.setNamesrvAddr("192.168.142.134:9876");
        producer.start();
        for (int i = 0; i < 20; i++) {
            Message message = new Message("tp_demo_10", ("hello qch"+i).getBytes());
            message.setDelayTimeLevel(i);
            SendResult result = producer.send(message);

        }

        producer.shutdown();


    }
}
